package com.aoxon.cargo.shared;

import android.util.Log;

import com.aoxon.cargo.bean.Location;
import com.aoxon.cargo.util.DataUtil;
import com.baidu.platform.comapi.basestruct.GeoPoint;

public class LocationShared extends MyShared {

    /**
     * 获取最近一次位置信息
     */
    public static GeoPoint getLastLocation() {
        String strGeoPoint = sp.getString("GeoPoint", "");

        if (!strGeoPoint.equals("")) {
            Log.e("STRING_GEOPOINT", strGeoPoint);
            Location loc = DataUtil.gson.fromJson(strGeoPoint, Location.class);
            Log.e("STRING_GEOPOINT", strGeoPoint);
            return new GeoPoint(loc.getLatitude(), loc.getLongitude());
        }
        return null;
    }

    /**
     * 保存最后的位置信息
     * 
     * @param geoPoint
     */
    public static void saveLostLocatioin(GeoPoint geoPoint) {
        if (geoPoint != null) {
            Location loc = new Location(geoPoint.getLatitudeE6(), geoPoint.getLongitudeE6());
            saveDate("GeoPoint", gson.toJson(loc));
        }
    }

}
